package webreg.model;

import javax.xml.bind.annotation.XmlAccessOrder;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;

import webreg.model.exceptions.EmptyNameException;

/** Class for club data in athletics
 * 
 * @author STKNOLL
 */
@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
@XmlAccessorType(XmlAccessType.NONE)
public class Club implements Cloneable{

	@XmlAttribute(name = "name")
	private String mClubname;
	@XmlElement(name = "contact")
	private String mContact;
	@XmlAttribute(name = "street")
	private String mStreet;
	@XmlAttribute(name = "postcode")
	private String mPostcode;
	@XmlAttribute(name = "city")
	private String mCity;
	@XmlAttribute(name = "country")
	private String mCountry;
	@XmlElement(name = "phone")
	private String mPhone;
	@XmlElement(name = "fax")
	private String mFax;
	@XmlElement(name = "eMail")
	private String mEmail;
	@XmlElement(name = "clubNumber")
	private String mClubNumber;
	@XmlElement(name = "leagueNumber")
	private String mLeagueNumber;	

	/** Constructor for a club
	 */
	public Club() {
		this.mClubname = "";
		this.mContact = "";
		this.mStreet = "";
		this.mPostcode = "";
		this.mCity = "";
		this.mCountry = "Deutschland";
		this.mPhone = "";
		this.mFax = "";
		this.mEmail = "";
		this.mClubNumber = "";
		this.mLeagueNumber = "";
	}

	/** Constructor for a club with parameters
	 * 
	 * @param clubname The name of the club
	 * @param street The street of the club address
	 * @param postcode The postcode of the club address
	 * @param city The city the city of the club address
	 * @throws EmptyNameException 
	 */
	public Club(String clubname, String street, String postcode, String city) throws EmptyNameException {
		this();
		setClubname(clubname);
		setStreet(street);
		setPostcode(postcode);
		setCity(city);
	}
	
	/** Constructor for a club with parameters
	 *
	 * @param clubname The name of the club
	 * @param contact The contact person of the club
	 * @param street The street of the address
	 * @param address_part2 The street part2 of the address
	 * @param postcode The postcode of the address
	 * @param city The city of the address
	 * @param country The country of the address
	 * @param phone The phone number of the club
	 * @param fax The fax number of the club
	 * @param clubNumber The club number of the club
	 * @param leagueNumber The league number of the club
	 * @throws EmptyNameException 
	 */
	public Club(String clubname, String contact, String street, String postcode, String city, String country, String phone, String fax, String mail, String clubNumber, String leagueNumber) throws EmptyNameException {
		this(clubname, street, postcode, city);
		setContact(contact);
		setCountry(country);
		setPhone(phone);
		setFax(fax);
		setEmail(mail);		
		setClubNumber(clubNumber);
		setLeagueNumber(leagueNumber);
	}
	
	/** Copy constructor for a club
	 * 
	 * @param toCopy The club to copy the data from
	 * @throws EmptyNameException 
	 */
	public Club(Club toCopy) {
		this();
		mClubname = toCopy.mClubname;
		mContact = toCopy.mContact;
		mStreet = toCopy.mStreet;
		mPostcode = toCopy.mPostcode;
		mCity = toCopy.mCity;
		mCountry = toCopy.mCountry;
		mPhone = toCopy.mPhone;
		mFax = toCopy.mFax;
		mEmail = toCopy.mEmail;
		mClubNumber = toCopy.mClubNumber;
		mLeagueNumber = toCopy.mLeagueNumber;
	}
	
	/** Implementation of the equal function of a club
	 * 
	 * @param toCompare The club to compare with
	 * @return True if the club matched, else false
	 */
	public boolean equals(Club toCompare) {
		if (toCompare.mClubname.equals(this.mClubname) == false) return false;
		if (toCompare.mContact.equals(this.mContact) == false) return false;
		if (toCompare.mStreet.equals(this.mStreet) == false) return false;
		if (toCompare.mPostcode.equals(this.mPostcode) == false) return false;
		if (toCompare.mCity.equals(this.mCity) == false) return false;
		if (toCompare.mCountry.equals(this.mCountry) == false) return false;
		if (toCompare.mPhone.equals(this.mPhone) == false) return false;
		if (toCompare.mFax.equals(this.mFax) == false) return false;
		if (toCompare.mEmail.equals(this.mEmail) == false) return false;
		if (toCompare.mClubNumber.equals(this.mClubNumber) == false) return false;
		if (toCompare.mLeagueNumber.equals(this.mLeagueNumber) == false) return false;
		return true;
	}
	

	/** Return the clubname
	 * @return The clubname
	 */
	public String getClubname() {
		return mClubname;
	}

	/** Set the clubname of the club
	 * @param clubname The name to set
	 * @throws EmptyNameException 
	 */
	public void setClubname(String clubname) throws EmptyNameException {
		if ((clubname == null) || (clubname.trim().equals(""))) throw new EmptyNameException( "Club" ); 
		this.mClubname = clubname;
	}

	/** Return the contact person of the club
	 * @return The contact 
	 */
	public String getContact() {
		return mContact;
	}

	/** Set the contact person of the club
	 * @param contact The contact to set
	 */
	public void setContact(String contact) {
		this.mContact = contact;
	}

	/** Return the stree of a club
	 * @return The street
	 */
	public String getStreet() {
		return this.mStreet;
	}

	/** Set the street of a club
	 * @param street The street to set
	 */
	public void setStreet(String street) {
		this.mStreet = street;	
	}
	
	/** Return the postcode of the club
	 * @return The postcode
	 */
	public String getPostcode() {
		return mPostcode;
	}

	/** Set the postcode of the club
	 * @param postcode The postcode to set
	 */
	public void setPostcode(String postcode) {
		this.mPostcode = postcode;
	}

	/** Return the city of the club address
	 * @return The city
	 */
	public String getCity() {
		return mCity;
	}

	/** Set the city of the club
	 * @param city The city to set
	 */
	public void setCity(String city) {
		this.mCity = city;
	}

	/** Return the country of the club
	 * @return the country
	 */
	public String getCountry() {
		return mCountry;
	}

	/** Set the country of the club
	 * @param country The country to set
	 */
	public void setCountry(String country) {
		this.mCountry = country;
	}
	
	/** Return the phone number of the club
	 * @return the phone
	 */
	public String getPhone() {
		return mPhone;
	}

	/** Set the phone number of the club
	 * @param phone The phone number to set
	 */
	public void setPhone(String phone) {
		this.mPhone = phone;
	}
	
	/** Return the fax number of the club
	 * @return The fax number
	 */
	public String getFax() {
		return mFax;
	}

	/** Set the fax number of the club
	 * @param fax The fax number to set
	 */
	public void setFax(String fax) {
		this.mFax = fax;
	}
	
	/** Return the eMail of an club
	 * @return the eMail address
	 */
	public String getEmail() {
		return this.mEmail;
	}

	/** Set the eMail address of the club
	 * @param eMail The eMail address to set
	 */
	public void setEmail(String eMail) {
		this.mEmail = eMail;
	}	
	
	/** Set the league number of the club
	 * @return the league number
	 */
	public String getLeagueNumber() {
		return mLeagueNumber;
	}

	/** Set the league number of the club
	 * @param leagueNumber The league number to set
	 */
	public void setLeagueNumber(String leagueNumber) {
		this.mLeagueNumber = leagueNumber;
	}

	/** Return the club number of the club
	 * @return The club number
	 */
	public String getClubNumber() {
		return mClubNumber;
	}

	/** Set the club number of the club
	 * @param clubNumber The club number to set
	 */
	public void setClubNumber(String clubNumber) {
		this.mClubNumber = clubNumber;
	}

	@Override
	public Object clone() {
		Club newClub = new Club();
		newClub.mClubname = mClubname;
		newClub.mContact = mContact;
		newClub.mStreet = mStreet;
		newClub.mPostcode = mPostcode;
		newClub.mCity = mCity;
		newClub.mCountry = mCountry;
		newClub.mPhone = mPhone;
		newClub.mFax = mFax;
		newClub.mEmail = mEmail;
		newClub.mClubNumber = mClubNumber;
		newClub.mLeagueNumber = mLeagueNumber;
		return newClub;
	}
	


}
